<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>v-on绑定事件</title>
    <script src="node_modules/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
    <!--直接写js片段-->
    <button v-on:click="num++">增加</button>
    <!--使用函数名,该函数必须在vue实例中定义-->
    <!--v-on:click的简写形式@click-->
    <button @click="decrement">减少</button>
    <h2>
        num = {{ num }}
    </h2>
</div>
<script type="text/javascript">
    var app = new Vue({
        el: "#app",
        data: {
            num: 1
        },
        methods: {
            decrement() {
                this.num--;
            }
        }
    });
</script>
</body>
</html>